export function byteFroamt(data) {
    //将存储格式转换为易读格式
    let oData = String(data).toUpperCase()
    const fullLevel = ["B", "KB", "MB", "GB", "TB",
        "PB", "EB", "ZB", "YB", "BB",
        "NB", "DB", "CB", "XB"]
    let res = oData.match(/(\d+)\s*(\w*)/i)
    let level = 0

    //获取当前存储格式
    switch (res[2]) {
        case "": case "B": level = 0; break;
        case "K": case "KB": level = 1; break;
        case "M": case "MB": level = 2; break;
        case "G": case "GB": level = 3; break;
        case "T": case "TB": level = 4; break;
        case "P": case "PB": level = 5; break;
        case "E": case "EB": level = 6; break;
        case "Z": case "ZB": level = 7; break;
        case "Y": case "YB": level = 8; break;
        case "BB": level = 9; break;
        case "N": case "NB": level = 10; break;
        case "D": case "DB": level = 11; break;
        case "C": case "CB": level = 12; break;
        case "X": case "XB": level = 13; break;
        default: break;
    }

    let space = parseInt(res[1])

    //大于1024时则转换格式，默认保留两位数
    while (space > 1024 && level < 13) {
        space = Math.round(space / 1024 * 100) / 100;
        level++
    }

    return space + fullLevel[level]

}
